// 把yun-design中定义的颜色值给替换掉
export default function vitePluginRoot() {
  return {
    name: 'vite-plugin-root',
    transform(code, id) {
      if (id.endsWith('theme.scss')) {
        code = code.replace(/:root :root/g, ':root');
        code = code.replace(/:root/g, ':root:root');
        const regex = /:root:root\s*{[^}]*--el-color-primary:\s*var\(--el-color-primary-light-5\);[^}]*}/g;
        code = code.replace(regex, '');
      }
      return {
        code,
        map: null,
      };
    },
  };
}
